package cn.go.bus;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import cn.go.buster.ThreadMode;
import cn.go.buster.annotation.GoBus;
import cn.go.buster.launcher.api.GoBuster;

/**
 * @author logcat
 */
public class MainActivity extends AppCompatActivity {

    private String TAG = this.getClass().getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        GoBuster.getInstance().register(this);
        startActivity(new Intent(this , SecondActivity.class));

    }



    @GoBus(tag = "tag1" , threadMode = ThreadMode.MAIN)
    public void testMethod(String value) {
        Log.d(TAG, "testMethod: " + value);
        Toast.makeText(this, "testMethod" + value, Toast.LENGTH_SHORT).show();
    }

    @GoBus(tag = "tag2" , threadMode = ThreadMode.MAIN)
    public void testMethod2() {
        Log.d(TAG, "testMethod2: ");
        Toast.makeText(this, "testMethod2", Toast.LENGTH_SHORT).show();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        GoBuster.getInstance().unRegister(this);
    }
}